package com.zx.guice;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import junit.framework.TestCase;

import com.google.common.base.Throwables;
import com.google.inject.Guice;
import com.google.inject.Injector;

/**  
 * @author zhaoxiang   
 * 测试Guice  
 */  
public class TestGuice extends TestCase {   
	public static Logger logger = LoggerFactory.getLogger(TestGuice.class);
	
    public void testHelloGuice() throws URISyntaxException {   
        Injector injector = Guice.createInjector(new HelloGuiceModule());   
//        Injector injector = Guice.createInjector();   
        HelloGuice helloGuice = injector.getInstance(HelloGuice.class);   
        helloGuice.sayHello();
        TestGuice.<UserInfo>print(UserInfo.class);
        HelloGuiceModule module = injector.getInstance(HelloGuiceModule.class);
        
        ClassLoader cl = Thread.currentThread().getContextClassLoader();

        URL url = cl.getResource(".");

        File folder =  new File(url.toURI());
        logger.error(folder.toString());
    }   
    
    public static <T> void print(Class<? extends T> vo){
    	logger.info(vo.toString());
    }
} 